{* Import Jquery Easy UI for TreeGrid *}
<script type="text/javascript" src="{$smarty.const.URL_FULL}modules/formhelpermodule/js/formhelper.js"></script>
{foreach from=$_css_files item='css_file'}
<link rel="stylesheet" type="text/css" href="{$css_file}">
{/foreach}
{foreach from=$_js_files item='js_file'}
<script type="text/javascript" src="{$js_file}"></script>
{/foreach}

<h1>{formhelper_lang key=$_title}</h1>
	<table id="{$_grid_id}" {if count($_toolbar_items) > 0 || ($_toolbar_html != '')} toolbar="#{$_toolbar_id}"{/if} >
		{if $_columns_type == 0}
		<thead>
			<tr>
				{foreach from=$_columns item='col'}
					<th {formhelper_list obj=$col}>{formhelper_lang key=$col->title}</th>
				{/foreach}
			</tr>
		</thead>
		{* Only load data if we has data, and grid type is datagrid and we have columns *}
		{if count($_data) > 0 && $_grid_type == 0}
		<tbody>
		{foreach from=$_data item='fhrdata' name='fh' key='fhk'}
		<tr>
			{foreach from=$_columns item='col'}
				{assign var='temp_key' value=$col->field}
				{if isset($fhrdata->$temp_key)}
					<td>{$fhrdata->$temp_key}</td>
				{/if}
			{/foreach}
		</tr>
		{/foreach}
		</tbody>
		{/if}
		{/if}
	</table>
	
	{if count($_toolbar_items) > 0 || ($_toolbar_html != '')}
	<div id="{$_toolbar_id}" {if $_toolbar_style !=''}style="{$_toolbar_style}"{/if}>
		{* List all toolbar items *}
		{foreach from=$_toolbar_items item='item'}
			<a href="javascript:void(0);" class="easyui-linkbutton" iconCls="icon-{$item->icon}" plain="true" onclick="{$item->onclick}">{formhelper_lang key=$item->title}</a>
		{/foreach}
		{$_toolbar_html}
	</div>
	{/if}
	
	{* Context menu *}
	{if count($_context_items) > 0 || ($_context_html != '')}
	<div id="{$_context_id}" class="easyui-menu" {if $_context_style !=''}style="{$_context_style}"{/if}>
		{foreach from=$_context_items item='item'}
			<div onclick="{$item->onclick}" iconCls="icon-{$item->icon}">{formhelper_lang key=$item->title}</div>
		{/foreach}
		{$_context_html}
	</div>
	{/if}
	{* End Context menu *}

	<script language="javascript">
		
		var _link_url='{$_action_url}';
		var _fh_grid_type = {$_grid_type};
		var _fh_context_id = '{$_context_id}';
		var _fh_toolbar_id = '{$_toolbar_id}';
		
		var _fh_options = {ldelim}
			{* Options *}
			{formhelper_list obj=$_grid_option deli1=' , ' deli2 = ':'}
			{if $_columns_type == 1}
				{* Frozen Columns *}
				{if count($_fozencolumns) > 0} ,
					frozenColumns:[[{formhelper_list obj=$_fozencolumns deli1=' , ' deli2 = ':'}]]
				{/if}
				{* Columns *}
				{if count($_columns) > 0} ,
					columns:[[{formhelper_list obj=$_columns deli1=' , ' deli2 = ':'}]]
				{/if}
			{/if}
		{rdelim};
		jQuery(document).ready(function(){ldelim}
			__FormHelper_SetDefaultLocation('{$__loc->src}');
			__FormHelper_Init("{$_grid_id}","{$_grid_js_callback_initready}","{$_grid_js_preinit}");
		{rdelim});
	</script>
